package abs.dao;

import abs.domain.Monedas;

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.skyway.spring.util.dao.AbstractJpaDao;

import org.springframework.dao.DataAccessException;

import org.springframework.stereotype.Repository;

import org.springframework.transaction.annotation.Transactional;

/**
 * DAO to manage Monedas entities.
 * 
 */
@Repository("MonedasDAO")
@Transactional
public class MonedasDAOImpl extends AbstractJpaDao<Monedas> implements
		MonedasDAO {

	/**
	 * Set of entity classes managed by this DAO.  Typically a DAO manages a single entity.
	 *
	 */
	private final static Set<Class<?>> dataTypes = new HashSet<Class<?>>(Arrays.asList(new Class<?>[] { Monedas.class }));

	/**
	 * EntityManager injected by Spring for persistence unit absV2
	 *
	 */
	@PersistenceContext(unitName = "absV2")
	private EntityManager entityManager;

	/**
	 * Instantiates a new MonedasDAOImpl
	 *
	 */
	public MonedasDAOImpl() {
		super();
	}

	/**
	 * Get the entity manager that manages persistence unit 
	 *
	 */
	@Override
	public EntityManager getEntityManager() {
		return entityManager;
	}

	/**
	 * Returns the set of entity classes managed by this DAO.
	 *
	 */
	@Override
	public Set<Class<?>> getTypes() {
		return dataTypes;
	}

	/**
	 * JPQL Query - findMonedasByCo010descContaining
	 *
	 */
	@Override
	@Transactional
	public Set<Monedas> findMonedasByCo010descContaining(String co010desc) throws DataAccessException {

		return findMonedasByCo010descContaining(co010desc, -1, -1);
	}

	/**
	 * JPQL Query - findMonedasByCo010descContaining
	 *
	 */

	@Override
	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Monedas> findMonedasByCo010descContaining(String co010desc, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findMonedasByCo010descContaining", startResult, maxRows, co010desc);
		return new LinkedHashSet<Monedas>(query.getResultList());
	}

	/**
	 * JPQL Query - findMonedasByCo010clca
	 *
	 */
	@Override
	@Transactional
	public Monedas findMonedasByCo010clca(String co010clca) throws DataAccessException {

		return findMonedasByCo010clca(co010clca, -1, -1);
	}

	/**
	 * JPQL Query - findMonedasByCo010clca
	 *
	 */

	@Override
	@Transactional
	public Monedas findMonedasByCo010clca(String co010clca, int startResult, int maxRows) throws DataAccessException {
		try {
			Query query = createNamedQuery("findMonedasByCo010clca", startResult, maxRows, co010clca);
			return (abs.domain.Monedas) query.getSingleResult();
		} catch (NoResultException nre) {
			return null;
		}
	}

	/**
	 * JPQL Query - findMonedasByCo010moneContaining
	 *
	 */
	@Override
	@Transactional
	public Set<Monedas> findMonedasByCo010moneContaining(String co010mone) throws DataAccessException {

		return findMonedasByCo010moneContaining(co010mone, -1, -1);
	}

	/**
	 * JPQL Query - findMonedasByCo010moneContaining
	 *
	 */

	@Override
	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Monedas> findMonedasByCo010moneContaining(String co010mone, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findMonedasByCo010moneContaining", startResult, maxRows, co010mone);
		return new LinkedHashSet<Monedas>(query.getResultList());
	}

	/**
	 * JPQL Query - findMonedasByCo010desc
	 *
	 */
	@Override
	@Transactional
	public Set<Monedas> findMonedasByCo010desc(String co010desc) throws DataAccessException {

		return findMonedasByCo010desc(co010desc, -1, -1);
	}

	/**
	 * JPQL Query - findMonedasByCo010desc
	 *
	 */

	@Override
	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Monedas> findMonedasByCo010desc(String co010desc, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findMonedasByCo010desc", startResult, maxRows, co010desc);
		return new LinkedHashSet<Monedas>(query.getResultList());
	}

	/**
	 * JPQL Query - findMonedasByPrimaryKey
	 *
	 */
	@Override
	@Transactional
	public Monedas findMonedasByPrimaryKey(String co010clca) throws DataAccessException {

		return findMonedasByPrimaryKey(co010clca, -1, -1);
	}

	/**
	 * JPQL Query - findMonedasByPrimaryKey
	 *
	 */

	@Override
	@Transactional
	public Monedas findMonedasByPrimaryKey(String co010clca, int startResult, int maxRows) throws DataAccessException {
		try {
			Query query = createNamedQuery("findMonedasByPrimaryKey", startResult, maxRows, co010clca);
			return (abs.domain.Monedas) query.getSingleResult();
		} catch (NoResultException nre) {
			return null;
		}
	}

	/**
	 * JPQL Query - findMonedasByCo010mone
	 *
	 */
	@Override
	@Transactional
	public Set<Monedas> findMonedasByCo010mone(String co010mone) throws DataAccessException {

		return findMonedasByCo010mone(co010mone, -1, -1);
	}

	/**
	 * JPQL Query - findMonedasByCo010mone
	 *
	 */

	@Override
	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Monedas> findMonedasByCo010mone(String co010mone, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findMonedasByCo010mone", startResult, maxRows, co010mone);
		return new LinkedHashSet<Monedas>(query.getResultList());
	}

	/**
	 * JPQL Query - findAllMonedass
	 *
	 */
	@Override
	@Transactional
	public Set<Monedas> findAllMonedass() throws DataAccessException {

		return findAllMonedass(-1, -1);
	}

	/**
	 * JPQL Query - findAllMonedass
	 *
	 */

	@Override
	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Monedas> findAllMonedass(int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAllMonedass", startResult, maxRows);
		return new LinkedHashSet<Monedas>(query.getResultList());
	}

	/**
	 * JPQL Query - findMonedasByCo010clcaContaining
	 *
	 */
	@Override
	@Transactional
	public Set<Monedas> findMonedasByCo010clcaContaining(String co010clca) throws DataAccessException {

		return findMonedasByCo010clcaContaining(co010clca, -1, -1);
	}

	/**
	 * JPQL Query - findMonedasByCo010clcaContaining
	 *
	 */

	@Override
	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Monedas> findMonedasByCo010clcaContaining(String co010clca, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findMonedasByCo010clcaContaining", startResult, maxRows, co010clca);
		return new LinkedHashSet<Monedas>(query.getResultList());
	}

	/**
	 * Used to determine whether or not to merge the entity or persist the entity when calling Store
	 * @see store
	 * 
	 *
	 */
	@Override
	public boolean canBeMerged(Monedas entity) {
		return true;
	}
}
